﻿// $Id$
/*! \file
 * \brief Definition of Northwind.DomainModel.Data.CustomerMapper.
 *
 * \author $Author$
 * \date $Date$
 * \version $Revision$
 */

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using Salamanca.DataAccess;
using Salamanca.DataAccess.Collections;
using Salamanca.DataAccess.Data;

namespace Northwind.DomainModel.Data
{



    ///////////////////////////////////////////////////////////////////////////
    ///
    /// <summary />
    ///
    ///////////////////////////////////////////////////////////////////////////

    public partial class CustomerMapper:
        DataMapper<Customer, Customer.PrimaryKey, Customer.DataTransfer>,
        ICustomerMapper
    {

        /// <summary />
        public CustomerMapper(DbConnection connection, ICacheManager cacheManager):
            base(connection, DomainModelCreator.CreateDefault<Customer>(), cacheManager)
        {
            _ParameterBuilder=new ParameterBuilder(connection);
        }

        /// <summary />
        public DomainModelKeyedCollection<Customer> FindAll(DataMapperCollection dataMappers)
        {
          return _FindAll(dataMappers);
        }

        /// <summary />
        protected override IList<IDbCommand> CreateSelectCommands(Customer.PrimaryKey key)
        {
            return CreateSelectCommands(Connection, ParameterBuilder, key);
        }

        /// <summary />
        protected override IList<IDbCommand> CreateDeleteCommands(Customer.DataTransfer data)
        {
            return CreateDeleteCommands(Connection, ParameterBuilder, (Customer.DataTransfer)data);
        }

        /// <summary />
        protected override IList<IDbCommand> CreateInsertCommands(Customer.DataTransfer data)
        {
            return CreateInsertCommands(Connection, ParameterBuilder, (Customer.DataTransfer)data);
        }

        /// <summary />
        protected override IList<IDbCommand> CreateUpdateCommands(Customer.DataTransfer data)
        {
            return CreateUpdateCommands(Connection, ParameterBuilder, (Customer.DataTransfer)data);
        }

        /// <summary />
        protected override Customer.DataTransfer GetDataTransferObject(IList<IDataRecord> records)
        {
          return _GetDataTransferObject(records);
        }

        /// <summary />
        internal static IList<IDbCommand> CreateSelectCommands(IDbConnection connection, ParameterBuilder parameterBuilder, Customer.PrimaryKey key)
        {
            return new IDbCommand[] { _CreateSelectCommand(connection, parameterBuilder, key) };
        }

        /// <summary />
        internal static IList<IDbCommand> CreateDeleteCommands(IDbConnection connection, ParameterBuilder parameterBuilder, Customer.DataTransfer data)
        {
            return new IDbCommand[] { _CreateDeleteCommand(connection, parameterBuilder, (Customer.DataTransfer)data) };
        }

        /// <summary />
        internal static IList<IDbCommand> CreateInsertCommands(IDbConnection connection, ParameterBuilder parameterBuilder, Customer.DataTransfer data)
        {
            return new IDbCommand[] { _CreateInsertCommand(connection, parameterBuilder, (Customer.DataTransfer)data) };
        }

        /// <summary />
        internal static IList<IDbCommand> CreateUpdateCommands(IDbConnection connection, ParameterBuilder parameterBuilder, Customer.DataTransfer data)
        {
            return new IDbCommand[] { _CreateUpdateCommand(connection, parameterBuilder, (Customer.DataTransfer)data) };
        }

    }
}
